/**
 * @date     2020-09-09
 * @author   尹学江
 */
/**
 * 模拟添加接口
 */
export const add = (params, time = 0) => {
  console.log(params)
  return new Promise(function(resolve, reject) {
    setTimeout(() => {
      resolve({
        code: 1,
        msg: '添加成功'
      })
    }, time)
  })
}

/**
 * 模拟删除接口
 */
export const remove = (params, time = 0) => {
  console.log(params)
  return new Promise(function(resolve, reject) {
    setTimeout(() => {
      resolve({
        code: 1,
        msg: '删除成功'
      })
    }, time)
  })
}

/**
 * 模拟修改接口
 */
export const update = (params, time = 0) => {
  console.log(params)
  return new Promise(function(resolve, reject) {
    setTimeout(() => {
      resolve({
        code: 1,
        msg: '修改成功'
      })
    }, time)
  })
}

/**
 * 模拟获取接口
 */
export const getData = (params, data, time = 0) => {
  console.log(params)
  return new Promise(function(resolve, reject) {
    setTimeout(() => {
      resolve({
        code: 1,
        msg: '获取成功',
        data
      })
    }, time)
  })
}

/**
 * 模拟获取接口
 */
export const getListPage = (params, data, time = 0) => {
  // 模拟表格数据
  const tableData = {
    current: 1,
    pages: 1,
    records: [{}],
    size: 20,
    total: 1
  }
  data = data || tableData
  return getData(params, data, time)
}

/**
 * 模拟获取接口
 */
export const getListAll = (params, data = [{}], time = 0) => {
  return getData(params, data, time)
}

/**
 * 模拟获取接口
 */
export const getDetail = (params, data = {}, time = 0) => {
  return getData(params, data, time)
}
